package com.controller.library;

import java.io.IOException;
import java.io.UnsupportedEncodingException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bean.library.AppraisedPaper;

public class CheckGradeServlet extends HttpServlet{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	public void doGet(HttpServletRequest request,HttpServletResponse response){
		try {
			request.setCharacterEncoding("utf-8");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		AppraisedPaper appraisedPaper = (AppraisedPaper)request.getSession().getAttribute("appraisedPaper");
		int pageNum = Integer.parseInt(request.getParameter("submit_page_num"));
		AppraisedPaper partialAppraisedPaper = new AppraisedPaper();
		partialAppraisedPaper.setScore(appraisedPaper.getScore());
		partialAppraisedPaper.setSubjectList(appraisedPaper.getSubjectList((pageNum-1)*10, 10));
		partialAppraisedPaper.setPaperName(appraisedPaper.getPaperName());
		partialAppraisedPaper.setStartIndex(pageNum - 1);
		request.getSession().setAttribute("partialAppraisedPaper", partialAppraisedPaper);
		try {
			response.sendRedirect("/Exam1/student/page/grade.jsp?"+request.getQueryString());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
